package pl.edu.agh;

import java.util.List;

import javax.swing.JPanel;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;

public class ElFaroChartFactory {
	public JFreeChart createChart(List<Integer> results){
		XYSeries series = new XYSeries("Guests");		
		for(int i = 0; i < results.size(); i++){
			series.add(i, results.get(i));
		}
        XYSeriesCollection dataset = new XYSeriesCollection();
		dataset.addSeries(series);
		JFreeChart chart = null;
		
		chart = ChartFactory.createXYLineChart("Number of guests", // Title
				"Day", // x-axis Label
				"Number of guests", // y-axis Label
				dataset, // Dataset
				PlotOrientation.VERTICAL, // Plot Orientation
				false, // Show Legend
				true, // Use tooltips
				false // Configure chart to generate URLs?
				);
		return chart;
	}
	public JPanel createChartPanel(List<Integer> results){
		return new ChartPanel(createChart(results));
	}
}
